/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fiap.controler;

import br.com.fiap.model.Entidade;
import br.com.fiap.percistencia.ReclamacoesDAO;
import java.io.IOException;
import java.io.PrintWriter;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author rm64596
 */

@WebServlet (urlPatterns="/processarCadastroSatisfacao")

public class ProcessarSatisfacao extends HttpServlet {

    
    private ReclamacoesDAO persistir;
    private Entidade satisfacao;
    private PrintWriter writer;

   
    public void init() throws ServletException {
               
        persistir = new ReclamacoesDAO();
        
        satisfacao = new Entidade();
                 
    }
    
 
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
       writer = resp.getWriter();
        
       satisfacao.setNome(req.getParameter("nome"));
       satisfacao.setComentario(req.getParameter("comentario"));
       satisfacao.setProduto(req.getParameter("produtos"));
       satisfacao.setSatisfacao(req.getParameter("satisfacao"));
        
       persistir.persistirReclamacao(satisfacao);
               
       writer.println("Persistido com Sucesso !!" );
        
    }
    
    
    
}
